package com.iter.devbox.pattern.dynamicproxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**经纪人对象（代理角色）*/
public class BrokerHandler implements InvocationHandler {
	
	/**持有某个需要代理的对象的引用*/
	private Object object;
	
	public BrokerHandler(Object object) {
		this.object = object;
	}
	
	/**执行被代理的对象的方法*/
	@Override
	public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
		System.out.println("代理对象是：");
		Object obj = method.invoke(object, args);
		return obj;
	}
}
